package com.sskj.mine.asset;

import com.bulong.rudeness.RudenessScreenHelper;
import com.sskj.common.adapter.slimadapter.IViewInjector;
import com.sskj.common.adapter.slimadapter.SlimAdapter;
import com.sskj.common.adapter.slimadapter.SlimInjector;
import com.sskj.common.base.App;
import com.sskj.common.box.decoration.DividerLineItemDecoration;
import com.sskj.lib.base.BaseActivity;
import com.sskj.mine.R2;
import com.sskj.mine.account.data.AccountBean;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.sskj.mine.R;

import java.util.List;

import butterknife.BindView;

/**
 * @author Hey
 * Create at  2019/05/03
 */
public class TransferRecordsActivity extends BaseActivity<TransferRecordsPresenter> {
    @BindView(R2.id.account_list)
    RecyclerView recyclerView;
    @BindView(R2.id.right_tv)
    TextView rightTv;

    private SlimAdapter recordsAdapter;



    @Override
    public int getLayoutId() {
        return R.layout.mine_activity_transfer_records;
    }

    @Override
    public TransferRecordsPresenter getPresenter() {
        return new TransferRecordsPresenter();
    }

    @Override
    public void initView() {
        setTitle(App.INSTANCE.getString(R.string.mine_transferRecordsActivity1_j));
        rightTv.setVisibility(View.GONE);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new DividerLineItemDecoration(this)
                .setFirstDraw(false)
                .setLastDraw(false)
                .setPaintWidth((int) RudenessScreenHelper.pt2px(App.INSTANCE,20))
                .setDividerColor(color(R.color.transparent)));
        recordsAdapter = SlimAdapter.create().register(R.layout.mine_item_transfer, new SlimInjector<AccountBean>() {
            @Override
            public void onInject(AccountBean data, IViewInjector injector, List<Object> list) {
                injector
                        .text(R.id.name_tv, data.getMemo())
                        .text(R.id.time_tv, data.getAddtime())
                        .text(R.id.account_tv, data.getPrice() + data.getPname());

            }

        }).attachTo(recyclerView);
    }

    @Override
    public void initData() {

        mPresenter.transferRecord();
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, TransferRecordsActivity.class);
        context.startActivity(intent);
    }

    public void updateUI(List<AccountBean> data) {
        recordsAdapter.updateData(data);
    }
}
